//
//  AboutSRXController.swift
//  ShiZhe
//
//  Created by 陈卿伟 on 16/9/12.
//  Copyright © 2016年 陈卿伟. All rights reserved.
//

import UIKit

class AboutSRXController: MainViewController {
    var tableView:AboutTableView!
    var cell:AboutCell!
    var headView:AboutHeader!
    
    
    let leftArr = ["给山人行点个赞","微信公众号","我们的邮箱","用户协议","隐私声明"]
    

    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "关于山人行"
        self.addTableView()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }

}

//MARK:--UI
extension AboutSRXController{
    //添加tableView
    func addTableView(){
        tableView = AboutTableView(frame: MainBounds, style: .Grouped)
        tableView.delegate = self
        tableView.dataSource = self
        self.view.addSubview(tableView)
    }
}

//MARK:--tableView  delegate  datasource
extension AboutSRXController:UITableViewDelegate,UITableViewDataSource{
    func numberOfSectionsInTableView(tableView: UITableView) -> Int {
        return 2
    }
    
    
    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        switch section {
        case 0:
            return 3
        case 1:
            return 2
        default:
            return 0
        }
    }
    
    func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        switch section {
        case 0:
            return 222*SCALEH
        default:
            return 15*SCALEH
        }
    }
    
    func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        switch section {
        case 1:
            return 163*SCALEH
        default:
            return 0.1
        }
    }
    
    func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        if section == 0{
            headView = AboutHeader(frame: CGRect(x: 0,y: 0,width: WidthAPP,height: 222*SCALEH))
            return headView
        }else{
            return nil
        }
    }
    
    func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        if section == 1{
            let footView = UIView(frame: CGRect(x: 0,y: 0,width: WidthAPP,height: 163*SCALEH))
            let copyRightLabel = UILabel(frame: CGRect(x: 120*SCALEW,y: 109*SCALEH,width: 136*SCALEW,height: 35*SCALEH))
            copyRightLabel.text = "杭州山人网络科技有限公司©️2016 版权所有 "
            copyRightLabel.textAlignment = .Center
            copyRightLabel.numberOfLines = 2
            copyRightLabel.textColor = Theme.GrayColor
            copyRightLabel.font = BaseFunc.getLightFont(11)
            footView.addSubview(copyRightLabel)
            return footView
        }else{
            return nil
        }
    }
    
    
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        cell = AboutCell(style: UITableViewCellStyle.Default, reuseIdentifier: "aboutCell")
        switch  (indexPath as NSIndexPath).section {
        case 0:
            cell.leftLabel.text = leftArr[(indexPath as NSIndexPath).row]
        default:
            cell.leftLabel.text = leftArr[(indexPath as NSIndexPath).row+3]
        }
        return cell
    }
}













